package com.jdrx.sw.sewage.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jdrx.ocp.beans.constans.EDeleteFlag;
import com.jdrx.platform.commons.rest.beans.dto.IdDTO;
import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.SludgeAnalysisAddDTO;
import com.jdrx.sw.sewage.beans.dto.SludgeAnalysisQueryDTO;
import com.jdrx.sw.sewage.beans.dto.SludgeAnalysisUpdateDTO;
import com.jdrx.sw.sewage.beans.entity.SludgeAnalysisPO;
import com.jdrx.sw.sewage.beans.vo.base.PageVO;
import com.jdrx.sw.sewage.service.SludgeAnalysisService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "/api/sludgeAnalysis")
@Api(value = "污泥分析")
public class SludgeAnalysisApi {
	@Autowired
	private SludgeAnalysisService sludgeAnalysisService;
	
	@ApiOperation(value = "新增污泥分析")
    @PostMapping(value = "add")
    public ResponseVO<?> add(@RequestBody @Validated SludgeAnalysisAddDTO dto) {
		sludgeAnalysisService.add(dto);
        return ResponseFactory2.ok();
    }
	
	@ApiOperation(value = "修改污泥分析")
    @PostMapping(value = "update")
    public ResponseVO<?> update(@RequestBody @Validated SludgeAnalysisUpdateDTO dto) {
		sludgeAnalysisService.update(dto);
        return ResponseFactory2.ok();
    }
	
	@ApiOperation(value = "删除污泥分析")
    @PostMapping(value = "delete")
    public ResponseVO<?> delete(@RequestBody @Validated IdDTO<Long> dto) {
		SludgeAnalysisUpdateDTO dto2 = new SludgeAnalysisUpdateDTO();
		dto2.setId(dto.getId());
		dto2.setDeleteFlag(Integer.valueOf(EDeleteFlag.DELETE.getKey()));
		sludgeAnalysisService.update(dto2);
        return ResponseFactory2.ok();
    }
	
	@ApiOperation(value = "污泥分析分页列表")
    @PostMapping(value = "pageList")
    public ResponseVO<PageVO<SludgeAnalysisPO>> pageList(@RequestBody @Validated SludgeAnalysisQueryDTO dto) {
        return ResponseFactory2.ok(sludgeAnalysisService.pageList(dto));
    }
}